<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	request.setCharacterEncoding("utf-8");
%>
<%  
   if (request.getSession().getAttribute("Login") != null) 
   {
	    String message = (String) request.getSession().getAttribute("Login");
	    if (!message.equals("true"))
	    {
	     //如果登录标志不为true则跳转回登录页面
	     response.sendRedirect("index.jsp");
	    }
	    else
	    {
	    	request.getSession().setAttribute("Login","true");
	    }   
   }
   else
   {
    	response.sendRedirect("index.jsp");
   }
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>查看评论</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="ch-cn">
<style type="text/css">
	body 
	{
		background-color: #2E77ED;
	}
</style>

</head>
<body>
<%! 
	String nidtmp = "";
	boolean flag = true;
 %>
<div align="center">
		<p>&nbsp;</p>
		<table width="534" border="0" align="center">
			<tr>
				<td width="217"><div align="center"><a href="AddNewsMain.jsp">添加新闻</a><br></div></td>
				<td width="307"><div align="center"><a href="ShowNews?method=view">查看新闻</a> </div></td>
			</tr>
		</table>
</div>

	<c:choose>
		<c:when test="empty ${pageModel.list}">
			<c:if test="empty ${pageModel.list}"></c:if>
			<div align="center"><strong><font size="22" color="ff0000">暂无评论信息！</font></strong></div>
		</c:when>
		<c:otherwise>
			<div align="center"><table border="1" width="1024">
					<tr>
					  <td width="77" bgcolor="#33F2E9"><div align="center"><strong>序号</strong></div></td>
					  <td width="586" align="left" bgcolor="#33F2E9"><div align="center"><strong>内容</strong></div></td>
					  <td width="119" bgcolor="#33F2E9"><div align="center"><strong>评论人</strong></div></td>
					  <td width="139" bgcolor="#33F2E9"><div align="center"><strong>时间</strong></div></td>
					  <td width="69" bgcolor="#33F2E9"><div align="center"><strong>删除</strong></div></td>
					</tr>
					<c:forEach items="${pageModel.list}" var="comment" varStatus="cul">
						<c:choose>
							<c:when test="${(cul.count) %2 == 0}">
							<tr align="center" bgcolor="#009AD8">
							</c:when>
							<c:otherwise>
							<tr align="center" bgcolor="#FF8040">
						</c:otherwise>
						</c:choose>
						<script language="javascript"> 
						if(flag)
						{
							nidtmp = ${comment.nid};
							flag =false;
						}
						</script>
						<td>${cul.count}</td>
						<td>${comment.content}</td>
						<td><a href="ManagerClientUserServlet?method=manager&username=${comment.region}">${comment.region}</a></td>
						<td>${comment.ptime}</td>
						<td><div align="center"><a href="showCommentsServlet?method=commentdelete&currentPage=${pageModel.currentPage}&cid=${comment.cid}&nid=${comment.nid}" >删除</a></div></td>
					</c:forEach>
			</table></div>
		  <div><table width="1024" border="1" align="center" bgcolor="#009AD8">
                <tr><td bgcolor="#33F2E9"><div align="right">总记录：${pageModel.totalRecords} 当前：${pageModel.currentPage} / ${pageModel.totalPage}页 <a href="showCommentsServlet?method=choise&currentPage=${pageModel.previousPage}&nidtmp=${nidtmp}"  >上一页</a> <a href="showCommentsServlet?method=choise&currentPage=${pageModel.nextPage}&nidtmp=${nidtmp}" > 下一页</a> </div></td></tr>
          </table></div>
	  </c:otherwise>
	</c:choose>
</body>
</html>
